//
//  SalesConfirmationViewController.m
//  CareWithFriends
//
//  Created by Versatile Systems, Inc on 11/6/13.
//  Copyright (c) 2013 Muludiang. All rights reserved.
//

#import "SalesConfirmationViewController.h"

@interface SalesConfirmationViewController ()

@end

@implementation SalesConfirmationViewController

@synthesize tags;

-(IBAction)addTags:(id)sender{
    UIAlertView *tagsAlert = [[UIAlertView alloc] initWithTitle:nil message:@"Add some issue tags" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Submit tags", nil ];
    [tagsAlert setAlertViewStyle:UIAlertViewStylePlainTextInput];
    [tagsAlert setTag:1];
    [tagsAlert show];
    //NSLog(@"Tags added: %@", [[tagsAlert textFieldAtIndex:0] text]);
}

-(IBAction)postIssue:(id)sender{
    UIAlertView *postAlert = [[UIAlertView alloc] initWithTitle:nil message:@"Issue ready to be submitted" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Submit issue", nil ];
    //[tagsAlert setAlertViewStyle:UIAlertViewStylePlainTextInput];
    [postAlert setTag:2];
    [postAlert show];
    //NSLog(@"Tags added: %@", [[tagsAlert textFieldAtIndex:0] text]);
}

/* - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex{
    if (buttonIndex == 1)
        NSLog(@"TextField contents:%@",[[alertView textFieldAtIndex:0] text]);
} */


-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    if (alertView.tag == 1) {
        if (buttonIndex == 1) {
            /// do nothing here
        }
    }
    else if (alertView.tag == 2){
        //[self dismissViewControllerAnimated:YES completion:nil];
        [self performSelector:@selector(retunToTop) withObject:nil afterDelay:0.3];
    }
    
}

-(void)retunToTop{
    [self.navigationController popToRootViewControllerAnimated:YES];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
